<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard Template for Bootstrap</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">


    <style type="text/css">
        /* Chart.js */

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>

<body>
<div th:replace="~{common/commons::topbar}"></div>

<div class="container-fluid">
    <div class="row">
        <div th:replace="~{common/commons::sidebar(active='empList.html')}"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2>添加员工信息</h2>
            <form th:action="@{/addEmp}" method="post">
                <input type="hidden" id="msg" th:value="${msg}" >
                <input type="hidden" id="msgCode" th:value="${msgCode}" >
                <div class="form-group">
                    <label for="InputName">姓名</label>
                    <input name="employeename" type="text" class="form-control" id="InputName" placeholder="张三" required>

                </div>
                <div class="form-group">
                    <label for="InputIdcard">身份证号</label>
                    <input name="idcard" type="text" class="form-control" id="InputIdcard" placeholder="33900519981222XXXX" required>
                </div>
                <div class="form-group">
                    <label >性别</label>
                    <div class="form-check form-check-inline" >
                    <input class="form-check-input" type="radio" name="sex"  value="1" checked>
                    <label class="form-check-label">男</label>
                </div>
                    <div class="form-check form-check-inline" >
                        <input class="form-check-input" type="radio" name="sex"  value="2">
                        <label class="form-check-label">女</label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="InputAge">年龄</label>
                    <input name="age" type="text" class="form-control" id="InputAge" placeholder="25">
                </div>
                <div class="form-group">
                    <label for="InputTelephone">电话</label>
                    <input name="telephone" type="text" class="form-control" id="InputTelephone" placeholder="138****1234">
                </div>
                <div class="form-group">
                    <label for="InputAddress">地址</label>
                    <input name="address" type="text" class="form-control" id="InputAddress" placeholder="浙江省杭州市临安区青山湖街道杭电路1号">
                </div>
                <div class="form-group">
                    <label for="InputEmail1">邮箱</label>
                    <input name="email" type="text" class="form-control" id="InputEmail1" placeholder="123@123.com">
                </div>
                <div class="form-group">
                    <label>部门</label>
                    <!--提交的是部门的ID-->
                    <select class="form-control" name="departmentid" required>
                        <option value="">请选择</option>
                        <option  th:each="dept:${departments}" th:text="${dept.departmentname}" th:value="${dept.id}">1</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="InputPosition">职位</label>
                    <input name="position" type="text" class="form-control" id="InputPosition" value="员工" required>
                </div>
                <div class="form-group">
                    <label>入职日期</label>
                    <input name="date" type="text"  class="form-control" id="dateFormat" autocomplete="off" required>
                </div>

                <button type="submit" class="btn btn-primary">提交</button>
            </form>
        </main>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
<script type="text/javascript" th:src="@{/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/laydate/laydate.js}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.3.0/sweetalert2.all.min.js" integrity="sha512-HL3ljb5fSrMMfAiRxSP+EdI/KC1kl6gVIzCV7GaJ4yFWCpnrcGxPAmytnKk9KNigFhyICxOlgD+uuaS07t7RdQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
    //执行一个laydate实例
    laydate.render({
        elem: '#dateFormat',
        trigger:'click'//指定元素
    });
</script>
<script>
    $(function(){
        hint1();//页面加载时加载
    })
    function hint1(){
        // var message1=document.getElementById("msg1").value;
        // var messageCode1=document.getElementById("messageCode1").value;
        var msg1=$("#msg").val();//获取id为msg1隐藏域的value值
        var msgCode1=$("#msgCode").val();//获取Id为msgCode1隐藏域的value值
        console.log("msg:",msg1);
        console.log("messageCode:",msgCode1);
        if (msg1!=""&&msg1!=null){
            msg(msg1,msgCode1);
        }

    }
    function msg(mge,messageCode){

        if (messageCode == "200") {
            Swal.fire({
                icon: "info",
                title: "提示",
                text: mge,
                showConfirmButton: false,
                timerProgressBar: true,
                timer: 1500
            });
        } else {
            Swal.fire({
                icon: "info",
                title: "提示",
                text: mge,
                showConfirmButton: false,
                timerProgressBar: true,
                timer: 20000
            });
        }
    }
</script>
</body>

</html>